]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
st-widget: Add method to clear background-image
authorFlorian Müllner <fmuellner@gnome.org>
Fri, 21 Sep 2012 14:21:40 +0000 (16:21 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Mon, 24 Sep 2012 20:03:05 +0000 (22:03 +0200)
For performance reasons, resources required to paint a widget are
aggressively cached; we know of at least one case where our caching
prevents updating the used background-image correctly, so add explicit
API to clear all associated cache data.

https://bugzilla.gnome.org/show_bug.cgi?id=679268

src/st/st-widget.c
src/st/st-widget.h

index c867f7d446a72ee83244ce7cbc20ebf69fd53616..27cc2fbc6c95ef4edd0165d50d385c849f6aa2b2 100644 (file)
@@ -2760,3 +2760,38 @@ st_widget_get_focus_chain (StWidget *widget)
 {
   return ST_WIDGET_GET_CLASS (widget)->get_focus_chain (widget);
 }
+
+/**
+ * st_widget_clear_background_image:
+ * @widget: An #StWidget
+ *
+ * Force a reload of the background-image property. Usually properties
+ * are cached heavily to avoid unnecessary work on paint, this method
+ * will force the cache to be recreated.
+ */
+void
+st_widget_clear_background_image (StWidget *actor)
+{
+  GFile *file;
+  const char *path;
+  char *uri;
+
+  if (actor->priv->theme_node == NULL)
+    return;
+
+  path = st_theme_node_get_background_image (actor->priv->theme_node);
+  if (path == NULL)
+    return;
+
+  file = g_file_new_for_path (path);
+  uri = g_file_get_uri (file);
+
+  st_texture_cache_clear_uri (st_texture_cache_get_default (), uri);
+  st_theme_node_invalidate_paint_state (actor->priv->theme_node);
+
+  if (CLUTTER_ACTOR_IS_MAPPED (CLUTTER_ACTOR (actor)))
+    clutter_actor_queue_redraw (CLUTTER_ACTOR (actor));
+
+  g_object_unref (file);
+  g_free (uri);
+}
index eb9e4cec188ef22a64a767408e842a488ac6851b..b04defa7d72216f8134ee415a1bedf44676a3428 100644 (file)
@@ -142,6 +142,8 @@ ClutterActor *        st_widget_get_label_actor           (StWidget        *widg
 void                  st_widget_set_label_actor           (StWidget        *widget,
                                                            ClutterActor    *label);
 
+void                  st_widget_clear_background_image    (StWidget        *widget);
+
 /* Only to be used by sub-classes of StWidget */
 void                  st_widget_style_changed             (StWidget        *widget);
 StThemeNode *         st_widget_get_theme_node            (StWidget        *widget);